//
//  DingRtcView.m
//  ding_rtc
//
//  Created by FXY on 2025/7/30.
//

#import "DingRtcView.h"
#import "DingRtcManager.h"

@implementation DingRtcView

- (instancetype)initWithFrame:(CGRect)frame
               viewIdentifier:(int64_t)viewId
                    arguments:(id)args
              binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger {

    self = [super init];
    if (self) {
        _viewId = viewId;

        _canvas = [[DingRtcVideoCanvas alloc] init];
        _canvas.renderMode = DingRtcRenderModeAuto;
        
         

        UIView *renderView = [[UIView alloc] init];
        renderView.layer.zPosition = 0.0;
        _canvas.view = renderView;
        _view = renderView;
        [[DingRtcManager sharedInstance] addView:_viewId view:self];
    }
    return self;
}

- (UIView *)view {
    return _view;
}

- (void)dispose {
    [[DingRtcManager sharedInstance] removeView:_viewId];
    _view = nil;
    _canvas = nil;
}

@end

